Before allowing a user to record a sound, you must ensure that sound-recording hardware and software are installed. You can record sound through the microphone built into several Macintosh models, or through third-party sound input devices. Because low-level sound input device drivers handle communication between your application and the sound recording hardware, you do not need to know what type of microphone is available. Listing 0-3 defines a function that determines whether sound recording hardware is available.
Listing 3 Determining whether sound recording equipment is available
FUNCTION MyHasSoundInput: Boolean;
VAR
myFeature: LongInt;
myErr: OSErr;
BEGIN
myErr := Gestalt(gestaltSoundAttr, myFeature);
IF myErr = noErr THEN {test sound input device bit}
MyHasSoundInput := BTst(myFeature, gestaltHasSoundInputDevice)
ELSE
MyHasSoundInput := FALSE; {no sound features available}
END;
The MyHasSoundInput function defined in Listing 0-3 uses the Gestalt function to determine whether sound input hardware is available and usable on the current Macintosh computer. MyHasSoundInput tests the gestaltHasSoundInputDevice bit and returns TRUE if you can record sounds. MyHasSoundInput returns FALSE if you cannot record sounds (either because no sound input device exists or because the Sound Input Manager is not available).
For more information on the Gestalt function, see Inside Macintosh: Operating System Utilities .
| Previous | Chapter contents | Chapter top | Section top | Next |